#pragma once
#ifndef LIT__EDITOR__PROJECT__HH__
#define LIT__EDITOR__PROJECT__HH__

#include <LitEditorPrerequisites.h>
#include <LitEditorInstance.h>
#include <qtreewidget.h>

namespace Lit
{
	namespace Editor
	{
		class LIT_API Project: public QObject
		{
		protected:
			std::string				mFileExt;
			std::string				mSavePath;
			QTreeWidget *			mTree;
			QTreeWidgetItem *		mRoot;
			std::string				mName;
			Instance *				mInstance;
			bool					mCreated;
		public:
			Project(Instance * inst, QTreeWidget * tree, const std::string &name = "unnamed", const std::string &file_extension = ".project");
			virtual ~Project(void);
			
			bool isCreated() const{ return mCreated; }

			const QTreeWidget * getTreeWidget() const;
			QTreeWidget * getTreeWidget();
			
			const Instance* getInstance() const;
			Instance * getInstance();

			const QTreeWidgetItem * getRootTreeNode() const;
			QTreeWidgetItem * getRootTreeNode();
			
			const std::string &getName() const;

			void destroy();
			void create( const std::string &name );

			bool isSavePathDefined() const;
			void setSavePath( const std::string &path );
			const std::string &getSavePath() const;

			void setFileExtension( const std::string &ext );
			const std::string &getFileExtension() const;

			QTreeWidgetItem * createRootNode( const std::string &name, bool expanded = true, Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled );
			QTreeWidgetItem * createNode( const std::string &name, QTreeWidgetItem * parent, bool expanded = true, Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled );
			
			void setValue( QTreeWidgetItem * node, const std::string &val );
			void setWidget( QTreeWidgetItem * node, QWidget * w );

		protected:
			virtual void _destroyProject( ){}
			virtual void _createProject( const std::string &name ){}
		};
	};
};
#endif